package exception;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.sql.SQLOutput;

/**
 * java异常处理机制：try...catch
 * try{
 *     代码片段
 * }catch（XXXException e){
 *     当try的代码片段出现XXException时的补救措施
 * }
 */
public class TryCatchDemo {
    private static Object NullPointerException;
    private static Object StringIndexOutOfBoundsException;
/*
    public static void main(String[] args) {
        System.out.println("程序开始了...");

        try {
            String line = null;
            System.out.println(line.length()); //由JVM给new了个空指针异常出来

            String line1 = "";
            System.out.println(line.charAt(0));

            String line2 = "abc";
            System.out.println(Integer.parseInt(line));
        }catch(NullPointerException e){
            System.out.println("出现了空指针异常并解决了");  //针对try中出现空指针异常的解决办法
        }catch(StringIndexOutOfBoundsException e){
            System.out.println("出现了字符串下标越界异常并解决了");//针对try中出现字符串下标越界异常
        }catch（NullPointerException | StringIndexOutOfBoundsException e){

        }
        }catch(Exception e){
        System.out.println("出错解决");//捕捉超类型异常，该异常的子类型被捕获并处理
    }
        System.out.println("程序结束了...");




    }

 */
}
